provider "alicloud" {
  region                = "cn-shenzhen"
}

terraform {
  required_version      = "~> 0.12"  
  backend "oss" {
    bucket              = "deeproute-terraform-resources"
    key                 = "demo/services/iac-example"
    tablestore_endpoint = "https://terraform-status.cn-shenzhen.ots.aliyuncs.com"
    tablestore_table    = "terraform_statelock_table"    
    region              = "cn-shenzhen"
  }
}

module "sg" {
  # source                = "../../../modules/alicloud/sg"
  source                = "git@code.deeproute.ai:deeproute-org/cloud/cloud/k8s-deployment/ops-terraform.git//alicloud/sg?ref=module.v1.0.3"
  sg_name               = "iac-example"
  vpc_id                = "vpc-wz94gvzjd0qnjti24e8is"
  inbound_rules         = {
    "0" = ["0.0.0.0/0", "22/22", "tcp"]
    "1" = ["0.0.0.0/0", "-1/-1", "icmp", "允许Ping"]
  }
}


resource "alicloud_instance" "instance" {
  count = 1
  instance_name   = "my-first-tf-vm"
  image_id        = "m-wz9ael9geijbpyi2cgqf"
  instance_type   = "ecs.c6.large"
  security_groups = [module.sg.sg_id]
  vswitch_id      = "vsw-wz93tv3xo2ljpg4qppg4e"
  # vswitch_id      = "vsw-wz9itft4zwi2waedturj6"
  system_disk_category = "cloud_essd"
  system_disk_performance_level = "PL0"
  # key_name  = "cloud-devops-key"
  password = "mi303258HU"

  tags = {
    from = "terraform"
  }
}